import {defineStore} from "pinia";
import {HomePageApi} from "../api/HomePageApi.js";


export const useHomePageStore = defineStore('useHomePageStore', {
    state: () => ({

        homePageButtons: {
            searchButton: {
                text: "",
                enable: true

            },
            operationButton: {
                text: "",
                enable: true
            },
            historyRecordButton: {
                text: "",
                enable: false
            }
        },

        button: {
            operation: "default",
            search: "default",
            historyRecord: "default"
        }
    }),
    actions: {
        goOperationPage() {
            this.router.push('/operation')
        },
        goSearchPage() {
            this.router.push('/search')
        },
        goHistoryRecord() {
            this.router.push('/historyRecord')
        },
        async initHomePage() {

            let initHomePage = await HomePageApi.initHomePage()
            this.homePageButtons = initHomePage.homePageButtons
        }
    }
})